﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web;
using System.Web.Security;
using System.Data;
using Library.Bll;
using Library.Common;
namespace HanhuaMicroCredit.BLL
{
    public class UserLog
    {
        public static void InsUserLog() { 
            string userName = Current.GetUserInfo("username");
            string VarIpaddress = HttpContext.Current.Request.UserHostAddress;
            ParameterInfo[] parameters = new ParameterInfo[]{
                new ParameterInfo("userName", DbType.String, userName),
                new ParameterInfo("ip", DbType.String, VarIpaddress),
            };
            string sql = "insert into Sys_IBsyslog(UserName,Ipaddress,Logtime,Logflag,IBBigClass,IBSmallClass,ontime,IsValid)";
            sql += " Values(@userName,@ip,GETDATE(),'登录成功','后台登录','',GETDATE(),1)";
            CommonBLL.ExecuteSQL4NonQuery(sql, parameters);
        }


        //获取用户角色
        public static List<int> GetUserRoles(string userId)
        {
            List<int> L = new List<int>();
            List<Dictionary<string,object>> LD = CommonBLL.GetList("sys_ibUserroles","*","","isvalid = 1 and userId ="+userId);
            if (LD.Count > 0) {
                foreach (Dictionary<string, object> d in LD) {
                    L.Add(Convert.ToInt32(d["roleId"]));
                }
            }
            return L;
        }

    }
}
